package com.retail.marketing.server.strategy;

import com.retail.marketing.common.req.ComputeReq;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * @author 33253
 */

//满减优惠卷计算类
@Component
public class FullMinusCoupon implements CouponStrategy {
    @Override
    public BigDecimal doActive(ComputeReq req) {
        //获取订单原价格跟满足条件价格作比较
        int i = req.getOrderPrice ().compareTo(req.getMinOrderAmount());
        if (i<0){
            //如果不满足条件就只接返回原价格
            return req.getOrderPrice ();
        }
        //满减金额相减价格返回
        return req.getOrderPrice ().subtract(req.getDiscountAmount());
    }
}
